package com.isdepci.project.carbon.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.isdepci.framework.aspectj.lang.annotation.Log;
import com.isdepci.framework.aspectj.lang.enums.BusinessType;
import com.isdepci.project.carbon.domain.GreenCertificatesListPurchaser;
import com.isdepci.project.carbon.service.IGreenCertificatesListPurchaserService;
import com.isdepci.framework.web.controller.BaseController;
import com.isdepci.framework.web.domain.AjaxResult;
import com.isdepci.common.utils.poi.ExcelUtil;
import com.isdepci.framework.web.page.TableDataInfo;

/**
 * 绿证-求购动态Controller
 *
 * @author isdepci
 * @date 2025-05-28
 */
@RestController
@RequestMapping("/carbon/purchaser")
public class GreenCertificatesListPurchaserController extends BaseController
{
    @Autowired
    private IGreenCertificatesListPurchaserService greenCertificatesListPurchaserService;

    /**
     * 查询绿证-求购动态列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:list')")
    @GetMapping("/list")
    public TableDataInfo list(GreenCertificatesListPurchaser greenCertificatesListPurchaser)
    {
        startPage();
        List<GreenCertificatesListPurchaser> list = greenCertificatesListPurchaserService.selectGreenCertificatesListPurchaserList(greenCertificatesListPurchaser);
        return getDataTable(list);
    }

    /**
     * 导出绿证-求购动态列表
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:export')")
    @Log(title = "绿证-求购动态", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(GreenCertificatesListPurchaser greenCertificatesListPurchaser)
    {
        List<GreenCertificatesListPurchaser> list = greenCertificatesListPurchaserService.selectGreenCertificatesListPurchaserList(greenCertificatesListPurchaser);
        ExcelUtil<GreenCertificatesListPurchaser> util = new ExcelUtil<GreenCertificatesListPurchaser>(GreenCertificatesListPurchaser.class);
        return util.exportExcel(list, "purchaser");
    }

    /**
     * 获取绿证-求购动态详细信息
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(greenCertificatesListPurchaserService.selectGreenCertificatesListPurchaserById(id));
    }

    /**
     * 新增绿证-求购动态
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:add')")
    @Log(title = "绿证-求购动态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GreenCertificatesListPurchaser greenCertificatesListPurchaser)
    {
        return toAjax(greenCertificatesListPurchaserService.insertGreenCertificatesListPurchaser(greenCertificatesListPurchaser));
    }

    /**
     * 修改绿证-求购动态
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:edit')")
    @Log(title = "绿证-求购动态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GreenCertificatesListPurchaser greenCertificatesListPurchaser)
    {
        return toAjax(greenCertificatesListPurchaserService.updateGreenCertificatesListPurchaser(greenCertificatesListPurchaser));
    }

    /**
     * 删除绿证-求购动态
     */
    @PreAuthorize("@ss.hasPermi('carbon:purchaser:remove')")
    @Log(title = "绿证-求购动态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(greenCertificatesListPurchaserService.deleteGreenCertificatesListPurchaserByIds(ids));
    }
}
